<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商务数据管理系统</title>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #34495e;
            --accent-color: #3498db;
            --light-color: #ecf0f1;
            --dark-color: #2c3e50;
            --success-color: #27ae60;
            --warning-color: #f39c12;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Noto Sans SC', sans-serif;
            background-color: #f5f7fa;
            color: var(--dark-color);
            line-height: 1.6;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 40px 20px;
        }
        
        header {
            text-align: center;
            margin-bottom: 40px;
        }
        
        h1 {
            font-size: 2.5rem;
            font-weight: 700;
            color: var(--primary-color);
            margin-bottom: 10px;
        }
        
        .subtitle {
            font-size: 1.1rem;
            color: var(--secondary-color);
            font-weight: 300;
        }
        
        .card {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
            padding: 30px;
            margin-bottom: 30px;
        }
        
        .button-group {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .btn {
            padding: 12px 24px;
            border: none;
            border-radius: 4px;
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        
        .btn-primary {
            background-color: var(--accent-color);
            color: white;
        }
        
        .btn-secondary {
            background-color: var(--secondary-color);
            color: white;
        }
        
        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }
        
        .btn-primary:hover {
            background-color: #2980b9;
        }
        
        .btn-secondary:hover {
            background-color: #2c3e50;
        }
        
        .btn i {
            margin-right: 8px;
        }
        
        .data-display {
            background-color: var(--light-color);
            border-radius: 6px;
            padding: 20px;
            height: 300px;
            overflow-y: auto;
            font-family: 'Courier New', Courier, monospace;
            font-size: 0.9rem;
            color: var(--dark-color);
            border: 1px solid #ddd;
        }
        
        .loading {
            display: none;
            text-align: center;
            margin: 20px 0;
        }
        
        .spinner {
            width: 40px;
            height: 40px;
            margin: 0 auto;
            border: 4px solid rgba(0, 0, 0, 0.1);
            border-radius: 50%;
            border-top-color: var(--accent-color);
            animation: spin 1s ease-in-out infinite;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        footer {
            text-align: center;
            margin-top: 40px;
            color: var(--secondary-color);
            font-size: 0.9rem;
        }
        
        .logo {
            max-width: 180px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <img src="https://via.placeholder.com/180x60?text=Company+Logo" alt="公司Logo" class="logo">
            <h1>商务数据管理系统</h1>
            <p class="subtitle">高效 · 精准 · 专业</p>
        </header>
        
        <div class="card">
            <div class="button-group">
                <button id="generateBtn" class="btn btn-primary">
                    <i>📊</i> 生成Excel文件
                </button>
                <button id="modifyBtn" class="btn btn-secondary">
                    <i>✏️</i> 修改Excel文件
                </button>
            </div>
            
            <div class="loading" id="loading">
                <div class="spinner"></div>
                <p>处理中，请稍候...</p>
            </div>
            
            <h2 style="margin-bottom: 15px;">项目分支数据</h2>
            <div class="data-display" id="dataDisplay">
                <p>正在加载数据...</p>
            </div>
        </div>
        
        <footer>
            <p>© 2023 商务数据管理系统 | 专业商务解决方案提供商</p>
        </footer>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 页面加载时获取分支数据
            fetchBranchData();
            
            // 生成Excel按钮点击事件
            document.getElementById('generateBtn').addEventListener('click', function() {
                callApi('/api/local/generateExcel', '正在生成Excel文件...');
            });
            
            // 修改Excel按钮点击事件
            document.getElementById('modifyBtn').addEventListener('click', function() {
                callApi('/api/local/modifyExcel', '正在修改Excel文件...');
            });
        });
        
        // 获取分支数据并显示
        function fetchBranchData() {
            const loading = document.getElementById('loading');
            const dataDisplay = document.getElementById('dataDisplay');
            
            loading.style.display = 'block';
            
            fetch('/api/user/escm/project/nebs/depot/nebs_web/git/list_branches', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .then(response => response.json())
            .then(data => {
                dataDisplay.innerHTML = `<pre>${JSON.stringify(data, null, 2)}</pre>`;
                loading.style.display = 'none';
            })
            .catch(error => {
                dataDisplay.innerHTML = `<p style="color: red;">获取数据失败: ${error.message}</p>`;
                loading.style.display = 'none';
            });
        }
        
        // 调用API函数
        function callApi(url, message) {
            const loading = document.getElementById('loading');
            loading.style.display = 'block';
            loading.querySelector('p').textContent = message;
            
            fetch(url, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .then(response => {
                if (response.ok) {
                    return response.json();
                }
                throw new Error('请求失败');
            })
            .then(data => {
                alert('操作成功完成！');
                loading.style.display = 'none';
            })
            .catch(error => {
                alert(`操作失败: ${error.message}`);
                loading.style.display = 'none';
            });
        }
    </script>
</body>
</html>